<div class="page-content-wrap row">
  <div class="col-md-4">
    <div class="panel panel-default">
      <div class="panel-heading ui-draggable-handle">
        <h4><%= t('camaleon_cms.admin.post_type.add_category')%> </h4>
      </div>
      <%= render partial: 'form' %>
    </div>
  </div>
   <div class="col-md-8">
  <!-- START BASIC TABLE SAMPLE -->
      <div class="panel panel-default">
        <div class="panel-heading ui-draggable-handle">
            <h4>
                <span class="fa fa-folder"></span> <%= "#{@post_type.decorate.the_title} / " if @post_type.present? %> <%= t('camaleon_cms.admin.post_type.categories', default: 'Categories') %>
            </h4>
        </div>
        <div class="panel-body">
          <table class="table table-responsive table-hover table-striped" id="categories-table-list">
            <thead>
            <tr>
              <th><%= t('camaleon_cms.admin.table.name')%></th>
              <th><%= t('camaleon_cms.admin.table.description')%></th>
              <th><%= t('camaleon_cms.admin.table.slug')%></th>
              <th><%= t('camaleon_cms.admin.table.qty')%></th>
              <%= r = {html: "", post_type: @post_type}; hooks_run("category_list_header", r); raw(r[:html]); %>
              <th><%= t('camaleon_cms.admin.table.actions')%></th>
            </tr>
            </thead>
            <tbody>
            <%
               def _item_html(item, pos = 0) item = item.decorate
                    %>
                    <tr data-id="<%= item.id %>" data-parent="<%= item.parent_id %>">
                      <td><%= raw('—' * pos) %> <%= item.the_title %></td>
                      <td><%= item.the_content %></td>
                      <td><%= item.the_slug %></td>
                      <td><%= item.count %></td>
                      <%= r = {html: "", post_type: @post_type, category: item}; hooks_run("category_list_body", r); raw(r[:html]); %>
                      <td>
                          <%= link_to raw('<i class="fa fa-eye"></i>'), item.the_url, target: '_blank', class: "btn btn-info btn-xs", title: "#{t('camaleon_cms.common.visit')}" %>
                          <%= link_to raw('<i class="fa fa-list"></i>'), cama_admin_post_type_taxonomy_posts_path(@post_type.id, "category", item.id), class: "btn btn-default btn-xs cama_ajax_request", title: "#{cama_pluralize_text(@post_type.decorate.the_title)} - #{item.the_title.to_s.titleize}" if @post_type.present? && (can? :posts, @post_type) %>
                          <%= link_to raw('<i class="fa fa-pencil"></i>'), {action: :edit, id: item.id }, class: "btn btn-default btn-xs cama_ajax_request", title: "#{t('camaleon_cms.admin.button.edit')}" %>
                          <%= link_to raw('<i class="fa fa-times"></i>'), { action: :destroy, id: item.id },method: :delete, data: { confirm: t('camaleon_cms.admin.message.delete') }, class: "btn btn-danger btn-xs cama_ajax_request", title: "#{t('camaleon_cms.admin.button.delete')}" unless item.get_option('not_deleted', false) %>
                      </td>
                    </tr>
                    <%
               end
               def _render_categories(categories, _level = 0)
                 categories.each do |term|
                   _item_html(term, _level)
                    children = term.children
                   _render_categories(children, _level + 1) if children.size > 0
                 end
               end
               _render_categories(@categories)
            %>
            </tbody>
          </table>
          <%= content_tag("div", raw(t('camaleon_cms.admin.message.data_found_list')), class: "alert alert-warning") if @categories.empty? %>
            <%= raw cama_do_pagination(@categories) %>
        </div>
      </div>
      <!-- END BASIC TABLE SAMPLE -->
    </div>
  </div>
  <!-- END PAGE CONTENT WRAPPER -->
</div>
